/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       game_application.h

	$Header: /game/game_application.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef GAME_APPLICATION_H_INCLUDED
#define GAME_APPLICATION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <map>
#include <string>

#include "sized_int_types.h"
#include "string_insensitive_compare.h"

// --------------------------------------------------------------------------------------
// abstract class for creating an application.  Created in winmain and called from there.
// --------------------------------------------------------------------------------------

struct	t_mouse_event;
struct	t_screen_point;
struct	t_screen_rect;
class	t_window;

typedef std::map<std::string, std::string,  t_string_insensitive_less> t_string_keyed_array;

class t_game_application
{
public:
	t_game_application();
	virtual ~t_game_application();
 
	static  void						close_help_balloon();
	void								create_arguments_map( std::string const& cmdline);
	static  void						exit( int return_value );
	static t_game_application const&	get();
	bool								get_command_line_argument( std::string const& key, 
																   std::string& result ) const;
	t_string_keyed_array const&			get_command_line_arguments_map() const;
	virtual t_uint32					idle();
	static bool							is_cursor_visible();
	virtual bool						menu_click( int id );
	void								mouse_move( t_window* window, t_mouse_event& event );
	virtual int							run();
	static void							set_cursor_visible( bool arg = true );
	static void							update_cursor(); 
	static void							update_cursor( t_window* window, t_screen_point const& point );

protected:
	virtual void initialize();


	t_string_keyed_array m_command_line_arguments;
};

inline bool t_game_application::get_command_line_argument( std::string const&	key,
														   std::string&			result ) const
{
	t_string_keyed_array::const_iterator index = m_command_line_arguments.find( key );

	if (index == m_command_line_arguments.end())
		return false;
	result = index->second;
	return true;
}

inline t_string_keyed_array const& t_game_application::get_command_line_arguments_map() const
{
	return m_command_line_arguments;
}

#endif // GAME_APPLICATION_H_INCLUDED
